Regression Plots


In [1]:
import seaborn as sns
%matplotlib inline

In [2]:
tips = sns.load_dataset('tips')

In [3]:
tips.head()


Out[3]:
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun Dinner 4

lmplot()


In [5]:
sns.lmplot(x='total_bill',y='tip',data=tips)


Out[5]:
<seaborn.axisgrid.FacetGrid at 0x117c81048>

In [6]:
sns.lmplot(x='total_bill',y='tip',data=tips,hue='sex')


Out[6]:
<seaborn.axisgrid.FacetGrid at 0x11bf59f98>

In [13]:
sns.lmplot(x='total_bill',y='tip',data=tips,hue='sex',palette='coolwarm')


Out[13]:
<seaborn.axisgrid.FacetGrid at 0x11d0ca080>

Working with Markers


In [16]:
# http://matplotlib.org/api/markers_api.html
sns.lmplot(x='total_bill',y='tip',data=tips,hue='sex',palette='coolwarm',
           markers=['o','v'],scatter_kws={'s':100})


Out[16]:
<seaborn.axisgrid.FacetGrid at 0x11d8ab748>

Using a Grid

We can add more variable separation through columns and rows with the use of a grid


In [28]:
sns.lmplot(x='total_bill',y='tip',data=tips,col='sex')


Out[28]:
<seaborn.axisgrid.FacetGrid at 0x1215cd048>

In [30]:
sns.lmplot(x="total_bill", y="tip", row="sex", col="time",data=tips)


Out[30]:
<seaborn.axisgrid.FacetGrid at 0x1226144e0>

In [24]:
sns.lmplot(x='total_bill',y='tip',data=tips,col='day',hue='sex',palette='coolwarm')


Out[24]:
<seaborn.axisgrid.FacetGrid at 0x11cbb02e8>

Aspect and Size

We can ajust the figure aspect and size by setting size and aspect parameters


In [36]:
sns.lmplot(x='total_bill',y='tip',data=tips,col='day',hue='sex',palette='coolwarm',
          aspect=0.6,size=8)


Out[36]:
<seaborn.axisgrid.FacetGrid at 0x12420e5c0>